import NetAdapter from "../adpapter/NetAdapter";
import GlobalData from "../GlobalData";
import AdManager from "../manager/AdManadgr";
import DeviceManager from "../manager/DeviceManager";
import { Util } from "../utils/Util";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Splash extends cc.Component {

    @property({ type: cc.Asset })
    manifestUrl: cc.Asset = null;

    private _storagePath: string;
    private versionCompareHandle: any;
    private _am: any;
    private _updating: boolean;

    onLoad() {
        console.log("Splash onLoad");
        NetAdapter.getUpdateHot().then((res: any) => {
            let info = res;
            if(info.is_update)
            {
                GlobalData.inst.tempHide = false;
            }else
            {
                GlobalData.inst.tempHide = true;
            }
            GlobalData.inst.is_alipay_transfer = info.is_alipay_transfer;//支付宝提现按钮
            GlobalData.inst.is_huifu_transfer = info.is_huifu_transfer;//汇服八方提现
            console.log("getUpdateHot info", res);

            //禁止观看广告的版本
            let versions_no_ad: any = res.versions_no_ad;
            console.log("getUpdateHot versions_no_ad", JSON.stringify(versions_no_ad));
            console.log("GlobalData.inst.version", GlobalData.inst.version);
            let is_no_ad = false;
            versions_no_ad.forEach(itemInfo => {
                // GlobalData.inst.version ="v1.250403.2111";
                if(itemInfo == GlobalData.inst.version)
                {
                    is_no_ad = true;
                }
            });
            GlobalData.inst.tempHide = is_no_ad;
            
        }).then(()=>{
                this.enterScene();
        })
    }

    loadSplash(){
        AdManager.inst.iosLoadSplash();
    }

    enterScene() {
        //跳转场景
        cc.director.loadScene("GameLauncher");
    }

    start() {

    }

    // update (dt) {}
}
